<?php 
set_time_limit(0);
ini_set("memory_limit", "12M");
if(!isset($_SESSION)) 
{ 
session_start(); 
} 
include_once '../value/value_kr.php';
unset($_SESSION['s_users']);

include_once 'checklogin.php';

include '../connection/connection.php';
$searchdate = date("Y-m-d");

$listSearch = mysql_query("SELECT l.logDate,l.logTime,c.szUser,l.iMode FROM caruser c,loglogin l where l.iUser= c.iUser and l.logDate='$searchdate' ",$connection);
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="x-ua-compatible" content="IE=edge" />
<link href="../css/style.css" rel="stylesheet" type="text/css" />
 <script type="text/javascript" src="../js/jquery.js"></script>

 <link rel="stylesheet" href="../css/jquery-ui.css" />
 <script type="text/javascript" src="../js/jquery-ui.js"></script>

<script type="text/javascript">
    $(function() {
        $( "#datepicker" ).datepicker({
            showOn: "button",
            buttonImage: "../images/calendar.gif",
            buttonImageOnly: true,
            dateFormat: "yy-mm-dd",
            autoSize: true
        });
    });
</script>
    
<script type="text/javascript">
$(document).ready(function(){
	ScrollTable();
});
function MyResize(){
	ScrollTable();
}

function ScrollTable(){
	wid = $("table#tablebody").parent().css('width');
	wid = wid.slice(0,-2)-18;
	$("table#tablebody").css("width", wid);
	$("table#tableheader").css("width", wid);
	$("table#tablebody").parent().scrollTop(0);
	OnTRCSS();
}

function OnTRCSS(){
	$("table.tbchung tr:even").each(function(){
		$(this).css("background-color","#eff3fa");
	});
}

</script>
<script type="text/javascript">
function OnSearch(){
	var winHf = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
	temp = $("#divscroll").position();
	var winH = parseInt(winHf - temp.top - 15);
	var s_date = $('#datepicker').val();//$("#s_month").val();
	if (s_date!==""){
		$.ajax({url:"ajax_users.php", data:{ s_date:s_date,winH:winH } , success:function(result){
			$("#tablebody tr").remove();
			$("#tablebody tbody").append(result);
			ScrollTable();
		}});
	}
}

function OnSearchSort(ele){
	var winHf = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
	temp = $("#divscroll").position();
	var winH = parseInt(winHf - temp.top - 15);
	flag = $(ele).attr('values');
	if(flag=='10'){
		$(ele).attr('values','11');
	}else if(flag=='11'){
		$(ele).attr('values','10');
	}
	else if(flag=='20'){
		$(ele).attr('values','21');
	}else if(flag=='21'){
		$(ele).attr('values','20');
	}
	else if(flag=='30'){
		$(ele).attr('values','31');
	}else if(flag=='31'){
		$(ele).attr('values','30');
	}
	else if(flag=='40'){
		$(ele).attr('values','41');
	}else if(flag=='41'){
		$(ele).attr('values','40');
	}
	$.ajax({url:"ajax_userssort.php", data:{ flag:flag,winH:winH } , success:function(result){
		$("#tablebody tr").remove();
		$("#tablebody tbody").append(result);
		ScrollTable();
	}});
}

function OnPagging(pageNum,rows_per_page,number_of_page){
	$.ajax({url:"ajax_userpagging.php", data:{ pageNum:pageNum,rows_per_page:rows_per_page,number_of_page:number_of_page } , success:function(result){
		$("#tablebody tr").remove();
		$("#tablebody tbody").append(result);
		ScrollTable();
		
	}});
	$.ajax({url:"ajax_userpaggingfooter.php", data:{ pageNum:pageNum,rows_per_page:rows_per_page,number_of_page:number_of_page } , success:function(result){
		$("#tablefooter tr").remove();
		$("#tablefooter tbody").append(result);

		$("table#tableheader th[name='th1']").attr('onclick',"OnSearchSort(this,"+pageNum+","+rows_per_page+")");
		$("table#tableheader th[name='th2']").attr('onclick',"OnSearchSort(this,"+pageNum+","+rows_per_page+")");
		$("table#tableheader th[name='th3']").attr('onclick',"OnSearchSort(this,"+pageNum+","+rows_per_page+")");
		$("table#tableheader th[name='th4']").attr('onclick',"OnSearchSort(this,"+pageNum+","+rows_per_page+")");
		
	}});
	
	
}
var winHf = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
function loadpos(){
	var currentsize = $("#tablebody tbody tr").size();
	var winHf = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
	temp = $("#divscroll").position();
	var realsize = winHf - temp.top - 15;
	$("#divscroll").css("height",parseInt(realsize));
	if(currentsize<parseInt(realsize/28)){
		temp =  parseInt(realsize/28)-currentsize+1;
		for (var i=0; i <=temp; i++){
			var tradd = "<tr><td width='25%'>&nbsp;</td><td width='25%'>&nbsp;</td>	<td width='25%'>&nbsp;</td>	<td width='25%'  class='last'>&nbsp;</td></tr>";
			$("#tablebody tbody").append(tradd);
		}
		OnTRCSS();
	}
	
}
</script>

</head>
<?php include 'show_function_popup_carcrime.php';?>
<body onresize="MyResize()" onload="loadpos();load_popup_carCrime()">
<p id="maylya" ><input type="hidden"  id="mayly" name="mayly" /></p>
<?php 
$monitor = $_REQUEST['monitor'];
$monitorname=$_REQUEST['monitorname'];
if (isset($_SESSION['monitor_menu'])) {
	$monitor = $_SESSION['monitor_menu'];
}
?>  
    <?php include 'menu.php';?>
    <div id="submenu">
    	<ul class="asubmenu">
    		<li><a href="searchcarnums.php?monitor=<?=$monitor?>&monitorname=<?=$monitorname?>"><?=$l_recognitionrate?></a></li>
        	<li><a href="carnums.php?monitor=<?=$monitor?>&monitorname=<?=$monitorname?>"><?=$l_s_canums?></a></li>
            <li><a href="trace.php?monitor=<?=$monitor?>&monitorname=<?=$monitorname?>" ><?=$l_s_trace?></a></li>
            <li><a href="cameras.php?monitor=<?=$monitor?>&monitorname=<?=$monitorname?>" ><?=$l_camera?></a></li>
            <li><a href="searchs.php?monitor=<?=$monitor?>&monitorname=<?=$monitorname?>" ><?=$l_s_searchs?></a></li>
            <li><a href="alarms.php?monitor=<?=$monitor?>&monitorname=<?=$monitorname?>" ><?=$l_s_alarms?></a></li>
            <li><a href="users.php?monitor=<?=$monitor?>&monitorname=<?=$monitorname?>"  class="asubmenuselect"><?=$l_s_users?></a></li>
        </ul>
        <div class="clear"></div>
    </div>
    <div class="main">
    	<table style="width:100%; padding:0px 0px 0px 0px; ">
    		<tr>
    			<td width="140">
    				<input type="text" id="datepicker" value="<?=$searchdate?>" style="width:100px;height:20;vertical-align: top"/>
    			</td>
    			
    			<td><input type="button" value="<?=$l_search?>" class="inbtn" style="width: 100px; height: 23px" onclick="OnSearch()" /></td>
    		</tr>
    	</table>
    	<div style="width:100%;height:5px"></div>
    	<div class="divtheader" >
	    	<table  cellpadding="0" cellspacing="0" border="0" width="100%" class="tbchung" id="tableheader" style="border:none;margin-top:0; min-height: 20px">
	               <tr>
	                   <th width="25%" name="th1" style="cursor: pointer;color: #027acc" onclick="OnSearchSort(this)" values="10"><?=$l_l_date?></th>
	                   <th width="25%" name="th2" style="cursor: pointer;color: #027acc" onclick="OnSearchSort(this)" values="20"><?=$l_time?></th> 
	                   <th width="25%" name="th3" style="cursor: pointer;color: #027acc" onclick="OnSearchSort(this)" values="30"><?=$l_user?></th>
	                   <th width="25%" name="th4" style="cursor: pointer;color: #027acc" onclick="OnSearchSort(this)" values="40" class="last"><?=$l_l_mode?></th> 
	               </tr>
	        </table>
        </div>
        <div id="divscroll"  style="overflow:scroll;overflow-x:hidden; width:100%; height:505px; background-color: #ffffff" >
               <table  cellpadding="0" cellspacing="0" border="0" width="99%" class="tbchung" style="margin-top:0" id="tablebody">
					<tbody>				 
				    <?php 
				    
					
					 $mylist = array();
					 $index =0;
					 while ($row = mysql_fetch_array($listSearch)){
					 	$index++;
					 	array_push($mylist, array($row[logDate],$row[logTime],$row[szUser],$row[iMode]));
					 	
					 ?>
					 <tr>
					 	<td width="25%"><?=$row[logDate]?></td>
					 	<td width="25%"><?=$row[logTime]?></td>
					 	<td width="25%"><?=$row[szUser]?></td>
					 	<td width="25%"  class="last"><?if ($row[iMode]==0){echo $l_login;}else if ($row[iMode]==1){echo $l_logout;}?></td>
					 </tr> 
					 <?php  
					 	
					 }
					 
					 $_SESSION['s_users'] = $mylist;
					 ?>  
				
      			</tbody>
               </table>
       </div>
      
       <!--div style="width:100%; padding:10 0">
       		<label>ëª¨ë‘� ë³´ê¸° &nbsp&nbsp</label>
       		<label style="width:1.5px; height: 30px;color: #ffffff; background-color: #ffffff">|</label>
       		<label>&nbsp adfasdfadf</label>
       </div>
       <div style="width:100%; padding:10 0; background-color: #ffffff">
       
       </div-->
              
    </div>
    <?php include 'show_content_popup_carcrime.php';?>
    <?php mysql_close($connection);?>
</body>     
</html>